package org.evelsoft.web.mbeans;

import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.evelsoft.common.interfaces.TestStatelessRemote;

/**
 *
 * @author wojtek
 */
@ManagedBean(name = "testMBean")
@SessionScoped
public class TestMBean {

	@EJB(name = "ejb/evelStateless")
	private TestStatelessRemote testStateless;
	//@EJB(name="ejb/myBean")
	//private TestStatefulRemote testStateful;
	private static int number = 0;
	private String output = "";
	private String name = "";
	private Integer nrAct;

	public TestMBean() {
		System.out.println("------JSF-----------");
		//System.getProperties().list(System.out);
		System.out.println("-------JSF----------");
	}

	public int getNumber() {
		return number++;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public String getOutputEJB() {
		return output;
	}

	public void setAction(Integer nrAct) {
		this.nrAct = nrAct;
	}

	public Integer getAction() {
		return nrAct;
	}

	public String testStatelessAction() {

		System.out.println("testStatelessAction->" + nrAct);
		if (nrAct == 1) {
			output = testStateless.testPersistence(name);
		} else if (nrAct == 2) {
			output = testStateless.testStateless(name);
		} else if (nrAct == 3) {
			output = testStateless.testSendMessage(name);
		} else if (nrAct == 4) {
			output = testStateless.testJBPM();
		} else {
			output = testStateless.testMethod(name);
		}
		return "";


	}

	public String testStatefulAction() {
		System.out.println("testStatefulAction->" + nrAct);
		if (nrAct == 1) {
			//output = testStateful.testPersistence(name);
		} else if (nrAct == 2) {
			//output = testStateful.testStatefull(name);
		} else if (nrAct == 3) {
			//output = testStateful.testSendMessage(name);
		} else {
			//output = testStateful.testMethod(name);
		}
		return "";
	}
}
